package AdvancedEncryptionStandard;

import org.apache.commons.codec.binary.Hex;

public class MiddleData {
    public static final ByteStream[] roundkeys = new ByteStream[11];
    private static final String[] keyStr = {"0f1571c947d9e8590cb7add6af7f6798", "dc9037b09b49dfe997fe723f388115a7",
            "d2c96bb74980b45ede7ec661e6ffd3c6", "c0afdf39892f6b675751ad06b1ae7ec0", "2c5c65f1a5730e96f222a390438cdd50",
            "589d36ebfdee387d0fcc9bed4c4046bd", "71c74cc28c2974bf83e5ef52cfa5a9ef", "37149348bb3de7f738d808a5f77da14a",
            "48264520f31ba2d7cbc3aa723cbe0b38", "fd0d42cb0e16e01cc5d54a6ef96b4156", "b48ef352ba98134e7f4d592086261876"};

    static class EncryptMiddleData {
        private ByteStream byteSub;
        private ByteStream shiftRow;
        private ByteStream mixColumn;
        private ByteStream addKey;

        private EncryptMiddleData(ByteStream byteSub, ByteStream shiftRow, ByteStream mixColumn, ByteStream addKey) {
            this.byteSub = byteSub;
            this.shiftRow = shiftRow;
            this.mixColumn = mixColumn;
            this.addKey = addKey;
        }

        public ByteStream getByteSub() {
            return byteSub;
        }

        public ByteStream getShiftRow() {
            return shiftRow;
        }

        public ByteStream getMixColumn() {
            return mixColumn;
        }

        public ByteStream getAddKey() {
            return addKey;
        }
    }

    public static final EncryptMiddleData[] encryptMiddleDatas = new EncryptMiddleData[11];
    private static final String[][] encryptMiddleDatasStr = {
            {"", "", "", "0e3634aece7225b6f26b174ed92b5588"},
            {"ab0518e48b403f4e897ff02f35f1fcc4", "ab40f0c48b7ffce489f1184e35053f2f",
                    "b9e447c5948e20d657169af575513f3b", "657470750fc7ff3fc0e8e8ca4dd02a9c"},
            {"4d92519d76c61675ba9b9b74e370e5de", "4dc69bde769be59dba705175e3921674",
                    "8eb2df2d22f280c5dbdcf71e1292c152", "5c7bb49a6b72349b05a2317ff46d1294"},
            {"4a218db87f4018146b3ac7d2bf3cc922", "4a40c7227f3ac9b86b3c8d14bf2118d2",
                    "b1baf91dc1f31f190b8b6a24cc07c35c", "7115262448dc747e5cdac7227da9bd9c"},
            {"a359f736528692f34a57c693ffd37ade", "a386c6de52577a364ad3f7f3ff599293",
                    "d43bcb191144abb7fe0662070f7337ec", "f867aee8b437a5210c24c1974cffeabc"},
            {"4185e49b8d9a06fdfe36788829168765", "419a78658d36879bfe16e4fd29850688",
                    "2a8384eb47e81810c418270a48ba23f3", "721eb200ba06206dcbd4bce704fa654e"},
            {"40723763f46fb73c1f486594f22d4d2f", "406f652ff4484d631f2d373cf272b794",
                    "7b1e949405d083c4422018434a4052fb", "0ad9d85689f9f77bc1c5f71185e5fb14"},
            {"673561b1a799682178a6688297d90ffa", "679968faa7a60fb178d9612197356882",
                    "ec0c3bb71a50d722c053007280c7efe0", "db18a8ffa16d30d5f88b08d777ba4eaa"},
            {"b9adc216323c0403413d300ef5f42fac", "b93c30ac323d2f1641f4c203f5ad040e",
                    "b13d0a9f1a2f6b6844ec2ff317b642b1", "f91b4fbfe934c9bf8f2f85812b084989"},
            {"99af84081e18dd087315970cf1303ba7", "991897a71e153b0873308408f1afdd0c",
                    "31ac466a3071651c3a8c4831c2c4eb62", "cca104a13e678500ff59025f3bafaa34"},
            {"4b32f232b285976316cb77cfe279ac18", "4b857718b2cbac321679f263e23297cf",
                    "", "ff0b844a0853bf7c6934ab4364148fb9"}
    };

    static {
        try {
            for (int i = 0; i < keyStr.length; i++) {
                roundkeys[i] = new ByteStream(Hex.decodeHex(keyStr[i]), 16);
            }
            for (int i = 0; i < encryptMiddleDatasStr.length; i++) {
                ByteStream byteSub = new ByteStream(Hex.decodeHex(encryptMiddleDatasStr[i][0]), 16);
                ByteStream shiftRow = new ByteStream(Hex.decodeHex(encryptMiddleDatasStr[i][1]), 16);
                ByteStream mixColumn = new ByteStream(Hex.decodeHex(encryptMiddleDatasStr[i][2]), 16);
                ByteStream addKey = new ByteStream(Hex.decodeHex(encryptMiddleDatasStr[i][3]), 16);
                encryptMiddleDatas[i] = new EncryptMiddleData(byteSub, shiftRow, mixColumn, addKey);
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

}
